{extend name="/index/base" /}

{block name="content"}
<div class="layui-card">
    <div class="layui-card-header layuiadmin-card-header-auto">
        <h2>添加角色</h2>
    </div>
    <div class="layui-card-body">
        <form class="layui-form" action="{:URL('admin/article/store')}" method="post">
            <div class="layui-form-item">
                <label for="" class="layui-form-label">权限名称</label>
                <div class="layui-input-block">
                    <input type="text" name="title" value="" lay-verify="required" placeholder="请输入关键词" class="layui-input title" >
                </div>
            </div>

            <div class="layui-form-item">
                <label for="" class="layui-form-label">权限描述</label>
                <div class="layui-input-block">
                    <textarea name="desc"  placeholder="请输入描述" class="layui-textarea desc"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <span type="submit" id="submit" class="layui-btn" lay-submit="" lay-filter="formDemo">确 认</span>
                    <a  class="layui-btn" href="{:URL('admin/auth/index')}" >返 回</a>
                </div>
            </div>

        </form>
    </div>
</div>

{/block}


{block name="script"}
<script>
    layui.use(['layer','table','form'],function () {
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var $ = layui.$ //由于layer弹层依赖jQuery，所以可以直接得到

        //搜索
        $('#submit').click(function () {
            var title = $(".title").val()
            var desc = $(".desc").val();

            var data = {'title':title,'desc':desc};

            $.ajax({
                type: 'POST',
                url: '{:url("admin/auth/store")}',
                data: data,
                success: function (ret) {
                    if (ret.code == 200) {
                        layer.msg(ret.msg, {icon: 6, time: 1000}, function () {
                            window.location.href='{:url("admin/auth/index")}';
                        });
                    }
                    return false;
                }
            });
        })


    })
</script>
{/block}
